import { ChunlianChItem } from "./ChunlianChItem";
import { GTileList } from "../../../../com/mui/controls/GTileList";
type int = number;
//class ChunlianChList
    
    export  class ChunlianChList /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.doubleClickEnabled = true;
            this.mouseEnabled = false;
            this.init();
            return;
        }

        public updateByChs(arg1: string): void
        {
            var loc1=null;
            var loc2=0;
            if (arg1 && !(arg1 == "")) 
            {
                loc2 = 0;
                while (loc2 < this._chItemsArray.length) 
                {
                    loc1 = this._chItemsArray[loc2];
                    loc1.index = loc2;
                    loc1.word = arg1.substr(loc2, 1);
                    ++loc2;
                }
            }
            return;
        }

        public set selectedIndex(arg1: int)
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._chItemsArray.length) 
            {
                loc1 = this._chItemsArray[loc2];
                loc1.selected = loc2 == arg1;
                ++loc2;
            }
            return;
        }

        public enableByIndex(arg1: int, arg2: Boolean, arg3: Boolean=false): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._chItemsArray.length) 
            {
                loc1 = this._chItemsArray[loc2];
                if (arg3) 
                {
                    loc1.enable = arg2;
                }
                else if (loc2 == arg1) 
                {
                    loc1.enable = arg2;
                }
                ++loc2;
            }
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            this._chItemsArray = new Array<any>();
            var loc2=0;
            while (loc2 < 16) 
            {
                loc1 = new ChunlianChItem();
                loc1.doubleClickEnabled = true;
                loc1.addEventListener(flash.events.MouseEvent.CLICK, this.onClickHandler);
                loc1.enable = true;
                loc1.x = loc2 % 4 * 75;
                loc1.y = int(loc2 / 4) * 60;
                this.addChild(loc1);
                this._chItemsArray.push(loc1);
                ++loc2;
            }
            return;
        }

        /* internal  */onClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target as ChunlianChItem;
            if (loc1 && loc1.enable) 
            {
                this.selectedIndex = loc1.index;
            }
            return;
        }

        /* internal */ /* var */_chItemsArray: Array<any>;

        /* internal */ /* var */_tileList: GTileList;
    }
